﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;

namespace Cataloger
{
    public class Raport
    {
        public static void GenerujRaport(Katalogi kat, string sciezka)
        {
            StreamWriter st = new StreamWriter(sciezka);
            st.WriteLine("Raport wykonany: " + DateTime.Now.ToShortDateString() + "  " + DateTime.Now.ToShortTimeString());
            st.WriteLine("---------------------------------------");
            st.WriteLine("Liczba katalogów: " + kat.Count.ToString());
            st.WriteLine("---------------------------------------");
            st.WriteLine("---------------------------------------");
            foreach (Katalog katal in kat)
            {
                st.WriteLine(katal.OpisWlasciwosci);
                st.WriteLine("---------------------------------------");
                st.WriteLine("---------------------------------------");
                foreach (Nosnik n in katal.Nosniki)
                {
                    st.WriteLine(n.OpisWlasciwosci);
                    st.WriteLine("---------------------------------------");
                    st.WriteLine("---------------------------------------");
                    RaportFoldRek(n.Root, st);
                    st.WriteLine();
                    st.WriteLine();

                }
                st.WriteLine();
                st.WriteLine();
            }
            st.Close();

        }
        private static void RaportFoldRek(Folder f, StreamWriter s)
        {
            foreach (Plik p in f.Pliki)
            {
                s.WriteLine(p.Sciezka);
            }
            foreach (Folder fol in f.Podflodery)
            {
                RaportFoldRek(fol, s);
            }
        }

    }
}
